#include <iostream>
#include <memory>
using namespace std;
//引用计数

int main()
{
    // shared_ptr<int> sp(new int(10));
    // cout<<*sp<<endl;
    // cout<<"cout:"<<sp.use_count()<<endl;

    // shared_ptr<int> sp2(sp);
    // cout<<"cout:"<<sp.use_count()<<endl;
    // cout<<"cout:"<<sp2.use_count()<<endl;


    int *p = new int(100);
    shared_ptr<int> sp(p);
    cout<<*sp<<endl;
    // {
    //     shared_ptr<int> sp2(sp);
    //     cout<<*sp2<<endl;
    //     cout<<"cout:"<<sp.use_count()<<endl;
    // }
    // cout<<"cout:"<<sp.use_count()<<endl;
    shared_ptr<int> sp3(sp);
    cout<<*sp3<<endl;
    cout<<"cout:"<<sp.use_count()<<endl;

    return 0;
}
